function [b1c,sD,sP1,sP2] = b1cSignalGen(tNum,PRN,fs,fifT,dIF,phi,dB)
%***北斗B1C中频信号生成器***%
%***导航电文由随机数代替****%
%-----------输出-----------%
% b1c  数字中频信号
%-----------输入-----------%
% PRN = 14;   % PRN号
% fs = 100e6; % 采样率 Hz
% fifT = 25e6;% 理论中频 Hz
% tNum = 1;   % 信号时长 秒
% dIF = 2625; % 载波频偏 Hz
% phi = 0.2;  % 相位偏移
% dB = -159;  % B1C全部分量总功率 dB
%**************************%
fcT = 1.023e6;       % 测距码理论速率
fif = fifT + dIF;    % 实际中频
fc = fcT + dIF/1540; % 实际码率(1575.42/1.023)
%% B1C
[mcD,mcP] = b1cMainCodeGen(PRN); % B1C主码(Main Code)
mcDB = BOC(mcD,1,1);            % MC Data分量BOC(1,1)调制
fmcdb = 2*fc;                   % Main Code Data BOC 码速率
mcPB1 = BOC(mcP,1,1);           % MC Pilot分量BOC(1,1)调制
fmcpb1 = 2*fc;                  % MCPB1 码速率
mcPB2 = BOC(mcP,6,1);           % MC Pilot分量BOC(6,1)调制
fmcpb2 = 12*fc;                 % MCPB2 码速率
scP = b1cSubCodeGen(PRN);       % 子码(SubCode) (仅Pilot分量有子码)
fscp = fc/10230;                % 子码速率
navD = 2*randi(2,[1e4,1])-3;    % 导航电文 (仅Data分量有导航电文)
fnav = fscp;                    % 导航电文速率 fscp==fnav
%% B1c
amp = 10^((dB+3)/20);
t   = (1/fs:1/fs:tNum).';
sD  = amp*1/2*navD(ceil(t*fnav)).*mcDB(mod(floor(t*fmcdb),length(mcDB))+1)...
    .*cos(2*pi*fif*t+phi);
sP1 = -amp*sqrt(29/44)*scP(ceil(t*fscp)).*mcPB1(mod(floor(t*fmcpb1),length(mcPB1))+1)...
    .*sin(2*pi*fif*t+phi);
sP2 = amp*sqrt(1/11)*scP(ceil(t*fscp)).*mcPB2(mod(floor(t*fmcpb2),length(mcPB2))+1)...
    .*cos(2*pi*fif*t+phi);
b1c = sD + sP1 + sP2;